enum week {
    Sun,
    Mon,
    Tue,
    Wed,
    Thu,
    Fri,
    Sat,
}
console.log(week[0] === 'Sun'); // true
console.log(week[1] === 'Mon'); // true
console.log(week[2] === 'Tue'); // true
console.log(week[3] === 'Wed'); // true

console.log(week[0] === 'Sun'); // true
console.log(week[1] === 'Mon'); // true
console.log(week[2] === 'Tue'); // true
console.log(week[6] === 'Sat'); // true

// 我们也可以给枚举项手动赋值：
enum Days {
    Sun = 7,
    Mon = 1,
    Tue,
    Wed,
    Thu,
    Fri,
    Sat,
}
(function (Days) {
    Days[(Days['Sun'] = 7)] = 'Sun';
    Days[(Days['Mon'] = 1)] = 'Mon';
    Days[(Days['Tue'] = 2)] = 'Tue';
    Days[(Days['Wed'] = 3)] = 'Wed';
    Days[(Days['Thu'] = 4)] = 'Thu';
    Days[(Days['Fri'] = 5)] = 'Fri';
    Days[(Days['Sat'] = 6)] = 'Sat';
})(Days || {});

// 常数枚举
const enum Directives {
    Up,
    Down,
    Left,
    Right,
}

let directives = [
    Directives.Up,
    Directives.Down,
    Directives.Left,
    Directives.Right,
];
console.log(directives);
// var directives = [0 /* Up */, 1 /* Down */, 2 /* Left */, 3 /* Right */];

// 外部枚举
declare const enum Directive {
    Up,
    Down,
    Left,
    Right,
}
let directions = [
    Directive.Up,
    Directive.Down,
    Directive.Left,
    Directive.Right,
];
console.log(directions);
// var directions = [0 /* Up */, 1 /* Down */, 2 /* Left */, 3 /* Right */];
